#!/bin/bash
OK=0
WARN=1
CRITICAL=2
UNKNOWN=3
PATH="/bin:/sbin:/usr/bin:/usr/sbin"

Ok_name=''
Fail_name=''
Judge=0
TTimeout=13
HName=`/bin/hostname -s`

function mount_l() {
                #/bin/mount -l > /tmp/mount_l_tmp
                #Temp=`grep $2 /tmp/mount_l_tmp |grep $1`
                Temp=`/bin/mount -l|grep -w $2 |grep $1`
                if [ "t$Temp" == "t" ]
                then
                        Judge=1
                        Fail_name="${Fail_name} ${choice}"
                else
                        Ok_name="${Ok_name} ${choice}"
                fi

                #continue

}



#if [ -e /etc/init.d/lustre ]
#if [ -e /etc/init.d/network ]
#then

#Lmount=`cat /etc/init.d/lustre  |grep "nms check"|awk -F : '{print $2}'`
#Lmount="scratchfs besfs" #dont forget if -e /etc/init.d/lustre
#for choice in besfs bes3fs publicfs besfs2 dybfs scratchfs workfs cefs  dyfs2 hpcfs
        ###

DomainName=`/usr/bin/hostname -d`
if [  "$DomainName" == "hep.ustc.edu.cn" ]
then
        Lmount="ustcfs ustcfs2 ustcfs3"
elif [  "$DomainName" == "hepg.sdu.edu.cn" ]
then
        Lmount="sdufs sdufs2 belle2fs"

elif [  "$DomainName" == "farm.lzu.edu.cn" ]  #lustre new site 
then
        Lmount="lzufs"
elif [  "$DomainName" == "hep.lzu.edu.cn" ]  #lustre new site
then
        Lmount="lzufs"
else
        echo "the remote site DomainName $DomainName is not in list"
        exit 2
fi


for choice in $Lmount
do
        case $choice in
        lustre)                                            ###
                mount_l  rw "10.15.91.111"
                ;;

        sdufs)                                             ###
                #mount_l  rw "10.200.3.13"   #/sdufs
                mount_l  rw "sdufs"   #/sdufs
		;;
	sdufs2)
                #mount_l  rw "10.200.3.20"   #/sdufs2
                mount_l  rw "sdufs2"   #/sdufs2
		;;
	belle2fs)
                #mount_l  rw "10.200.3.15"   #/belle2fs
                mount_l  rw "belle2fs"   #/belle2fs
                ;;


        ustcfs)                                            ###
                mount_l  rw "10.1.1.71"
                ;;
        ustcfs2)                                            ###
                mount_l  rw "10.1.1.81"
                ;;
        ustcfs3)                                            ###
                mount_l  rw "10.1.1.86"
                ;;
        home)                                            ###
                mount_l  rw "10.1.1.3"
                ;;

        lzufs)                                            ###
                mount_l  rw "210.72.11.150"
                ;;


        esac

done

/bin/rm -f /tmp/mount_l_tmp
scriptpath=$0
currentfilename=${scriptpath##*/}
if [ $Judge -eq 1 ]
then
        echo "mount -l $Fail_name  wrong status"
        #exit `/usr/lib64/nagios/plugins/updatecondorrelationlabel.sh $currentfilename $CRITICAL`
	exit 2
else
        echo " $Ok_name are OK "
        #exit `/usr/lib64/nagios/plugins/updatecondorrelationlabel.sh $currentfilename $OK`
	exit 0
fi

#else
#       echo "can not find file /etc/init.d/lustre"
#       exit $CRITICAL
#fi

